#include "log.hpp"
#include "shm.hpp"
#include "namepipe.hpp"
extern Log log;
int main()
{
    //获取共享内存
    int shmid=GetShareMem();
    char*shmaddr=(char*)shmat(shmid,nullptr,0);
    
    //打开管道，利用管道的互斥机制辅助共享内存通信
    int fd =open(path,O_WRONLY);
    if(fd<0)
    {
        log(Fatal, "open error, error string: %s, error code: %d", strerror(errno), errno);
        exit(-1);
    }
    while(1)
    {
       char c=0;
       fgets(shmaddr,4096,stdin);
       write(fd,&c,1);
    }
    shmdt(shmaddr);
    close(fd);
    return 0;
}